package com.weichuang.springBootRabbmitMQ.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lzzsrj.union.message.common.producer.Producer;
import lzzsrj.union.message.common.bean.UnionMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@Slf4j
@RestController
@RequestMapping("/union/message")
@RequiredArgsConstructor
public class MessageController {

    @Autowired
    private Producer producer;

    @PostMapping("/send")
    public String sendRedisMQ() {
//        log.info("开始发送消息");
        UnionMessage unionMessage = new UnionMessage().setData("1234567890");
        producer.send("create_policy", "", unionMessage);
        producer.send("create_policy", "", unionMessage, 10L, TimeUnit.SECONDS);
//        log.info("结束发送消息");
        return null;
    }


}
